<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资产维修列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>维修编号：</label>
                                <input type="text" name="repairsNo"/>
                            </li>
                            <li class="select-time">
                                <label>维修日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginRepairsTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endRepairsTime]"/>
                            </li>
                            <li>
                                <label>报修人：</label>
                                <input type="text" name="userName" />
                            </li>
                            <li>
                                <label>报修手机：</label>
                                <input type="text" name="userMobile"/>
                            </li>
                            <li>
                                <label>维修状态：</label>
                                <select name="repairsStatus" th:with="type=${@dict.getType('repairs_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>设备编号：</label>
                                <input type="text" name="assetsId"/>
                            </li>
                            <li>
                                <label>设备名称：</label>
                                <input type="text" name="assetsName"/>
                            </li>
                            <li>
                                <label>SN号：</label>
                                <input type="text" name="assetsSn"/>
                            </li>
                            <li>
                                <label>维修人：</label>
                                <input type="text" name="repairsUserName"/>
                            </li>
                            <li class="select-time">
                                <label>答复时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginRepairsAnswerTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endRepairsAnswerTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" >-->
                    <!--<i class="fa fa-plus"></i> 添加维修-->
                <!--</a>-->
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" >-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" >
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('assets:repairs:edit')}]];
        var removeFlag = [[${@permission.hasPermi('assets:repairs:remove')}]];
        var repairsStatusDatas = [[${@dict.getType('repairs_status')}]];
        var prefix = ctx + "assets/repairs";
        var flag = [[${flag}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                detailUrl: prefix + "/detail/{id}",
                exportUrl: prefix + "/export",
                modalName: "资产维修",
                sortName: "repairsStatus",                         // 排序列名称
                sortOrder: "asc",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'repairsId',
                    title: '',
                    visible: false
                },
                {
                    field: 'repairsNo',
                    title: '维修编号'
                },
                {
                    field: 'repairsTime',
                    title: '报修日期'
                },
                {
                    field: 'userName',
                    title: '报修人'
                },
                {
                    field: 'userMobile',
                    title: '报修手机'
                },
                {
                    field: 'repairsStatus',
                    title: '状态',
                    formatter: function(value, row, index) {
                        if(value == 1){
                            var actions = [];
                            actions.push('<span class="label label-warning">'+$.table.selectDictLabel(repairsStatusDatas, value)+'</span> ');
                            return actions.join('');

                        }else{
                            return $.table.selectDictLabel(repairsStatusDatas, value);
                        }

                    }
                },
                {
                    field: 'assetsId',
                    title: '设备编号'
                },
                {
                    field: 'assetsName',
                    title: '设备名称'
                },
                {
                    field: 'assetsSn',
                    title: 'SN号'
                },
                {
                    field: 'repairsUserName',
                    title: '操作人'
                },
                {
                    field: 'repairsAnswerTime',
                    title: '结单时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(flag==1) {
                            actions.push('<a class="btn btn-success btn-xs  href="javascript:void(0)" onclick="$.operate.edit(\'' + row.repairsId + '\')"><i class="fa fa-edit"></i>结单</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs  href="javascript:void(0)" onclick="$.operate.detail(\'' + row.repairsId + '\')"><i class="fa fa-flag-o"></i>查看</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>